<br /><br />
<form role="form" method="post">
    <div>
        <label for="competitionname">Competition Name:</label><br>
        <input type="text" name="competitionname" value="<?php echo $this->data;?>" disabled="disabled">
    </div>
   
     <br/>
    

     <br>
    <div id="output" class="out">
        <input type="button" name="button" onclick="question()" class="btn btn-primary" value="Add Question"> 
           <input type="submit"  class="btn btn-primary" value="Add "> 

    
    </div>
</form>


<script>
        var i=1;

function question(){
    var output = document.getElementById('output');
    var val="";
    

        if(!document.getElementById('timedrpact'+i))
        {
            var ele = document.createElement("div");
           var l = document.createElement("label");
             var n = document.createElement("div");

          var l2 = document.createElement("label");
                    var l3 = document.createElement("label");
                   var ind = document.createElement("input");
                             ind.type = "hidden";

                     //ind.setAttribute("value",i);

         var q = document.createElement("input");
         var w = document.createElement("br");
          q.type = "text";
          var a1 = document.createElement("input");
          a1.type = "text";
          var a2 = document.createElement("input");
          a2.type = "text";
          var a3 = document.createElement("input");
          a3.type = "text";
          var a4 = document.createElement("input");
          a4.type = "text";
            ele.setAttribute("id","timedrpact"+i);
            ele.setAttribute("class","inner");
            l.innerHTML="</br> write the question <br>    ";

            l2.innerHTML="</br > write answers    <br>";
           l3.innerHTML="</br > Correct Answer    <br>";
           q.setAttribute("name","q"+i);
           q.setAttribute("class","qu");
            a1.setAttribute("name","a"+i);
            a1.setAttribute("class","an");
            a2.setAttribute("name","b"+i);
            a2.setAttribute("class","an");
            a3.setAttribute("name","c"+i);
            a3.setAttribute("class","an");
            a4.setAttribute("name","d"+i);
            a4.setAttribute("class","an");
           
         ind.setAttribute("name","ind");
           ind.setAttribute("value",i);

            var taskList = document.createElement("select");
            taskList.innerHTML += "<option>a</option><option>b</option><option>c</option><option>d</option>";
            taskList.setAttribute("name","corr"+i);
            output.appendChild(ind);

            output.appendChild(ele);
            output.appendChild(w);
            output.appendChild(l); 
            output.appendChild(w);
             output.appendChild(w);output.appendChild(w);
            output.appendChild(q);
            output.appendChild(w);
            output.appendChild(l2); 
           
            output.appendChild(a1);
            output.appendChild(a2);
            

            
            output.appendChild(a3);
            
            output.appendChild(a4);
            
            output.appendChild(l3);

            output.appendChild(taskList);


            


        
        i++;


    }
};
</script>